home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Die Speccy' 97
/
Die Speccy' 97.iso
/
amiga_system
/
the_aminet
/
comm
/
fido
/
smartpoll.lha
/
SmartPoll.comp.rexx
next >
Wrap
OS/2 REXX Batch file
|
1995-09-16
|
10KB
|
2 lines
/* Optimized with RexxOpt 1.7 */
OPTIONS RESULTS;PARSE ARG ConfigName;SIGNAL ON BREAK_C;SIGNAL ON ERROR;SIGNAL ON HALT;Cr='0d'x;Lf='0a'x;IF ~Show('Libraries','rexxreqtools.library') THEN;DO;CALL AddLib('rexxreqtools.library',0,-30);END;ConOpen=0;TDStarted=0;IF ConfigName=''|ConfigName='CONFIGNAME' THEN;DO;IF ~Exists('Mail:SmartPoll.cfg')&Exists('Mail:Poll.cfg') THEN;DO;ConfigName='Mail:Poll.cfg';END;ELSE;DO;ConfigName='Mail:Poll.cfg';END;END;StartDate= Date('Internal');IF ~ReadConfig() THEN;DO;RETURN(20);END;IF Nodes=0 THEN;DO;SAY 'No nodes found in "'ConfigName'"';RETURN(10);END;CALL ReadData;CALL ScanOutBound;DoPoll=0;DO I=1 FOR Nodes;IF Node.I.ExtraPoll|(StartDate-Node.I.Poll>=Node.I.Days) THEN;DO;DoPoll=1;END;ELSE;DO;Node.I.Polled=1;END;END;IF ~DoPoll THEN;DO;SAY 'No node(s) need polling';RETURN(0);END;IF ~StartTD() THEN;DO;RETURN(20);END;ADDRESS VALUE RexxName;IF Open('Con',ConsoleName) THEN;DO;ConOpen=1;NodesLeft=Nodes;DO UNTIL NodesLeft<1;NodesLeft=Nodes;DO I=1 FOR Nodes;IF Node.I.Polled THEN;DO;NodesLeft=NodesLeft-1;ITERATE I;END;IF Node.I.Boss ~='' THEN;DO;'Boss 'Node.I.Boss;CALL WriteCh('Con','Calling 'Node.I.Boss', number: ');END;ELSE;DO;CALL WriteCh('Con','Calling: ');END;IF Node.I.Password ~='' THEN;DO;'Password 'Node.I.Password;END;DO J=1 FOR Node.I.0;CALL WriteCh('Con',Node.I.J'...');'Call ' Node.I.J;'Status X';SELECT;WHEN Result=0 THEN;DO;IF Node.I.ExtraPoll THEN;DO;Node.I.ExtraPoll=0;END;ELSE;DO;Node.I.Poll=StartDate;END;CALL WriteCh('Con','Transfer complete');Node.I.Polled=1;END;WHEN Result=5 THEN;DO;rtResult=0;IF DoAsk THEN;DO;CALL rtEZRequest('Do you want to continue polling this node?','_Yes|_No','SmartPoll request','RT_PubScrName='PubScreen);END;IF rtResult=0 THEN;DO;Node.I.Polled=1;END;END;WHEN Result=13|Result=15 THEN;DO;CALL WriteCh('Con','This node can t be polled (undialable node)');Node.I.Polled=1;END;WHEN Result=14 THEN;DO;CALL WriteCh('Con','Accounting limit reached');Node.I.Polles=1;END;WHEN Result=18 THEN;DO;NOP;END;WHEN Result=11|Result=22 THEN;DO;rtResult=0;IF DoAsk THEN;DO;CALL rtEZRequest('No answer from this node.'Lf'Do you want to continue polling this node?','_Yes| _No ','SmartPoll request','RT_PubScrName='PubScreen' RTEZ_Flags=EZREQF_CenterText');END;IF rtResult=0 THEN;DO;Node.I.Polled=1;END;END;OTHERWISE;DO;Node.I.Errors=Node.I.Errors+1;IF Node.I.Errors>=ErrorLimit THEN;DO;rtResult=0;IF DoAsk THEN;DO;CALL rtEZRequest('Error limit ('ErrorLimit') reached.'Lf'Do you want to continue polling this node?','_Keep polling|_Clear error count|_Stop polling','SmartPoll request','RT_PubScrName='PubScreen' RTEZ_Flags=EZREQF_CenterText');END;SELECT;WHEN rtResult=0 THEN;DO;Node.I.Polled=1;END;WHEN rtResult=2 THEN;DO;Node.I.Errors=0;END;OTHERWISE;DO;NOP;END;END;END;END;END;IF Node.I.Polled THEN;DO;NodesLeft=NodesLeft-1;LEAVE J;END;END;CALL WriteCh('Con',Lf);END;IF NodesLeft>0 THEN;DO;CALL WriteCh('Con',' 'RedialDelay' secs... 'Cr);DO I=RedialDelay-1 BY-1 FOR RedialDelay;CALL Delay(50);CALL WriteCh('Con',' 'I' secs... 'Cr);END;END;CALL WriteCh('Con',Lf);END;END;ELSE;DO;SAY "Couldn't open console window";END;SaveData:;IF ConOpen THEN;DO;CALL Close('Con');END;IF Open('Data','Mail:SmartPoll.data','W') THEN;DO;DO I=1 FOR Nodes;IF Node.I.Save THEN;DO;CALL WriteLn('Data',Node.I.Poll);END;END;CALL Close('Data');END;IF TDStarted THEN;DO;ADDRESS VALUE RexxName;'Quit';END;RETURN;ScanOutbound:;IF Crash| Direct|Normal|Request THEN;DO;IF ~Show('Libraries','traplist.library') THEN;DO;CALL AddLib('traplist.library',-5,-30);END;IF ~Show('Libraries','rexxsupport.library') THEN;DO;CALL AddLib('rexxsupport.library',0,-30);END;Files=ShowDir(Outbound,'File');DO J=1 FOR Words(Files);File=Word(Files,J);FileInfo=StateF(File);PARSE VAR FileInfo Type Size ' ' .;IF Size=0|Type='DIR' THEN;DO;ITERATE J;END;Ext=Upper(Right(File,4));SELECT;WHEN Ext='.CLO'|Ext='.CUT' THEN;DO;Type='crash';END;WHEN Ext='.DLO'|Ext='.DUT' THEN;DO;Type='direct';END;WHEN Ext='.FLO'|Ext='.OUT' THEN;DO;Type='normal';END;WHEN Ext='.REQ' THEN;DO;Type='request';END;OTHERWISE;DO;ITERATE J;END;END;IF (Crash&Type='crash')|( Direct&Type='direct')|(Normal&Type='normal')|(Request&Type='request') THEN;DO;PARSE VAR File Zone '.' Net '.' Node '.' Point '.' .;NodeNum=Zone':'Net'/'Node'.'Point;BossNum=0;DO I=1 FOR Ignores;IF Ignore.I=NodeNum THEN;DO;ITERATE J;END;END;DO I=1 FOR Akas;IF Aka.I.Also=NodeNum THEN;DO;NodeNum=Aka.I.Node;LEAVE I;END;END;DO I=1 FOR Nodes;IF (Node.I.Boss ~=''&Node.I.Boss=NodeNum)|(Node.I.1=NodeNum) THEN;DO;IF StartDate-Node.I.Poll<Node.I.Days THEN;DO;BossNum=I;END;ELSE;DO;ITERATE J;END;END;END;NodeName=FindNode(NodeNum,'System');NodeCity=FindNode(NodeNum,'Location');NodePassword=FindNode(NodeNum,'Password');IF SubStr(NodeName,1,1)='0'|SubStr(NodeCity,1,)=0 THEN;DO;IF DoAsk THEN;DO;CALL rtEZRequest("Couldn't find node "NodeNum" in current nodelist",' Ok ','Poll information','RT_PubScrName='PubScreen);END;ITERATE J;END;NodeName=SubStr(NodeName,3);NodeCity=SubStr(NodeCity,3);IF SubStr(NodePassword,1,1)='0' THEN;DO;NodePassword='';END;ELSE;DO;NodePassword=SubStr(NodePassword,3);END;IF DoAsk THEN;DO;IF BossNum>0 THEN;DO;InDays=Node.BossNum.Days-(StartDate-Node.BossNum.Poll);BossMsg=','Lf'a boss due for polling in 'InDays' day(s)';Gadgets='_Add|_Skip';END;ELSE;DO;BossMsg='';Gadgets='_Add|_Delete|_Skip';END;CALL rtEZRequest('Add node 'NodeNum||Lf'('type' file to 'NodeName' in 'NodeCity||BossMsg')'Lf'to the poll list?',Gadgets,'Poll request','RTEZ_Flags=EZREQF_CenterText RT_PubScrName='PubScreen);END;ELSE;DO;rtResult=1;END;IF rtResult=2 THEN;DO;CALL rtEZRequest('Really delete "'File'"'Lf'('type' file to'NodeName' in 'NodeCity')?',' _Ok |_Cancel','Poll request','RT_PubScrName='PubScreen' RTEZ_Flags=EZREQF_CenterText RTEZ_DefaultResponse=0');IF rtResult=1 THEN;DO;Delete(Outbound||File);Index=Index('.CLO.CUT.DLO.DUT',Ext);IF Index>0 THEN;DO;NewExt=SubStr('.CUT.CLO.DUT.DLO',Index,4);NewFile=Overlay(NewExt,File,Length(File)-4);Delete(NewFile);END;END;END;ELSE;DO;IF rtResult=0 THEN;DO;Node.I.Polled=1;END;IF BossNum>0 THEN;DO;Node.BossNum.ExtraPoll=1;END;ELSE;DO;Nodes=Nodes+1;I=Nodes;Node.I.0=1;Node.I.1=NodeNum;Node.I.Boss='';Node.I.Days=0;Node.I.Save=0;Node.I.Poll=StartDate-100;Node.I.Polled=0;Node.I.Errors=0;Node.I.ExtraPoll=0;IF Node.I.Password='' THEN;DO;Node.I.Password=NodePassword;END;END;END;END;END;END;RETURN;ReadConfig:;Nodes=0;Ignores=0;Akas=0;RexxName='TrapDoor';TrapDoorCmd='TrapDoor';PubScreen='TrapDoor';ConsoleName='Con:0/14/640/100/Poll.rexx/SCREEN TrapDoor';Outbound='Mail:Outbound/';RedialDelay=30;ErrorLimit=5;DoAsk=1;Crash=0;Direct=0;Normal=0;Request=0;IF ~Open('Config',ConfigName,'R') THEN;DO;SAY 'Couldn t open "'ConfigName'"';RETURN(0);END;DO LineNum=1 UNTIL Eof('Config');Line=ReadLn('Config');IF Words(Line)=0|SubStr(Line,1,1)='#' THEN;DO;ITERATE;END;IF Words(Line)<2 THEN;DO;SAY 'Missing argument on line 'LineNum' in "'ConfigName'"';ITERATE;END;Line=Translate(Line,' ','09'x);Cmd=Upper(Word(Line,1));Args=SubStr(Line,WordIndex(Line,2));SELECT;WHEN Cmd='REXXNAME' THEN;DO;RexxName=Args;END;WHEN Cmd='TDCMD' THEN;DO;TrapDoorCmd=Args;END;WHEN Cmd='CONSOLE' THEN;DO;ConsoleName=Args;END;WHEN Cmd='OUTBOUND' THEN;DO;Outbound=Args;LastChar=Right(Outbound,1);IF LastChar ~='/'&LastChar ~=':' THEN;DO;Outbound=Outbound'/';END;END;WHEN Cmd='PUBSCREEN' THEN;DO;PubScreen=Args;END;WHEN Cmd='REDAILDELAY'|Cmd='REDIALDELAY' THEN;DO;IF ~DataType(Args,'Numeric') THEN;DO;SAY 'Bad argument on line 'LineNum' in "'ConfigName'"';END;ELSE;DO;RedialDelay=Args;END;END;WHEN Cmd='ASK' THEN SELECT;WHEN Args='YES' THEN;DO;DoAsk=1;END;WHEN Args='NO' THEN;DO;DoAsk=0;END;OTHERWISE;DO;SAY 'Bad argument on line 'LineNum' in "'ConfigName'"';END;END;WHEN Cmd='ERRORLIMIT' THEN;DO;ErrorLimit=Args;END;WHEN Cmd='IGNORE' THEN;DO;Ignores=Ignores+1;Ignore.Ignores=Args;END;WHEN Cmd='AKA' THEN;DO;IF Words(Args)<2) THEN;DO;SAY 'Not enough arguments on line 'LineNum' in "'ConfigName'"';END;ELSE;DO;Akas=Akas+1;Aka.Akas.Node=Word(Args,1);Aka.Akas.Also=Word(Args,2);END;END;WHEN Cmd='POLL' THEN;DO J=1 FOR Words(Args);DoPoll=Word(Args,J);SELECT;WHEN DoPoll='CRASH' THEN;DO;Crash=1;END;WHEN DoPoll='NOCRASH' THEN;DO;Crash=0;END;WHEN DoPoll='DIRECT' THEN;DO;Direct=1;END;WHEN DoPoll='NODIRECT' THEN;DO;Direct=0;END;WHEN DoPoll='NORMAL' THEN;DO;Normal=1;END;WHEN DoPoll='NONORMAL' THEN;DO;Normal=0;END;WHEN DoPoll='REQUEST' THEN;DO;Request=1;END;WHEN DoPoll='NOREQUEST' THEN;DO;Request=0;END;OTHERWISE;DO;SAY 'Bad argument on line 'LineNum' in "'ConfigName'"';END;END;END;WHEN Cmd='NODE' THEN;DO;Nodes=Nodes+1;I=Nodes;Node.I.0=Words(Args)-2;Node.I.Poll=StartDate-100;Node.I.Polled=0;Node.I.Save=1;Node.I.ExtraPoll=0;Node.I.Password='';Node.I.Errors=0;IF Node.I.0<0 THEN;DO;SAY 'Argument(s) missing on line 'LineNum' in "'ConfigName'"';END;ELSE;DO;Node.I.Days=Word(Args,1);Node.I.Boss=Word(Args,2);IF Node.I.0>0 THEN;DO J=1 FOR Node.I.0;Node.I.J=Word(Args,J+2);END;ELSE;DO;Node.I.0=1;Node.I.1=Node.I.Boss;Node.I.Boss='';END;IF Node.I.0>1 THEN;DO;J=Node.I.0;IF Left(Node.I.J,3)='PW=' THEN;DO;Node.I.Password=SubStr(Node.I.J,4);Node.I.0=Node.I.0-1;END;ELSE IF Show('Libraries','traplist.library') THEN;DO;NodePassword=FindNode(Node.I.Boss,'Password');IF SubStr(NodePassword,1,1)='1' THEN;DO;Node.I.Password=SubStr(NodePassword,3);END;END;END;END;END;OTHERWISE;DO;SAY 'Unknown configuration command on line 'LineNum' in "'ConfigName'"';END;END;END;CALL Close('Config');RETURN(1);ReadData:;IF Open('Data','Mail:SmartPoll.data','R') THEN;DO;DO I=1 UNTIL Eof('Data')|I>Nodes;Line=ReadLn('Data');IF DataType(Line,'Numeric') THEN;DO;Node.I.Poll=Line;Node.I.OrigPoll=Line;END;END;CALL Close('Data');END;RETURN;StartTD:;IF ~Show('P',RexxName) THEN;DO;ADDRESS COMMAND;'Run >Nil: 'TrapDoorCmd' REXXNAME 'RexxName' ANSWER';'WaitForPort 'RexxName;IF Show('P',RexxName) THEN;DO;TDStarted=1;END;ELSE;DO;SAY "Couldn't start TrapDoor";RETURN(0);END;END;RETURN(1);ERROR:;SAY '+++ Error 'RC' on line 'SIGL': 'ErrorText(RC);HALT:;BREAK_C:;SIGNAL SaveData